#@admin_layout()
#define admin_main()
<fieldset class="layui-elem-field layui-field-title">
	<legend>新增博客</legend>
</fieldset>
#if(titleMsg || contentMsg || categoryMsg)
    <blockquote class="layui-elem-quote layui-text">
        #(titleMsg)
        #(contentMsg)
        #(categoryMsg)
    </blockquote>
#end
<form class="layui-form" action="/blog/save" method="post">
    <div class="layui-form-item">
        <input type="text" name="blog.title" value="#(blog.title??)"  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">博客内容</label>
        <textarea class="layui-textarea" id="LAY_demo1" style="display: none" name="blog.content">
            #(blog.content??)
        </textarea>
    </div>
    <div class="layui-form-item">
        <input type="text" name="blog.disc" value="#(blog.disc??)"  lay-verify="required" placeholder="请输入简介" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-form-item">
        <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
</form>
#end

#define admin_script()
<script>
	layui.use(['layedit','form'], function(){
		var layedit = layui.layedit
				,$ = layui.jquery;
        var form = layui.form;
		//构建一个默认的编辑器
		layedit.set({
			uploadImage: {
				url: '/file/upload'
			}
		});
		var index = layedit.build('LAY_demo1');

		//编辑器外部操作
		var active = {
			content: function(){
				alert(layedit.getContent(index)); //获取编辑器内容
			}
			,text: function(){
				alert(layedit.getText(index)); //获取编辑器纯文本内容
			}
			,selection: function(){
				alert(layedit.getSelection(index));
			}
			,add: function(){
				alert(layedit.getSelection(index));
			}
		};

		$('.site-demo-layedit').on('click', function(){
			var type = $(this).data('type');
			active[type] ? active[type].call(this) : '';

		});

        form.on('submit(formDemo)', function(data){
//            layer.msg(JSON.stringify(data.field));
//			return false;
        });
	});
</script>
#end